package com.xxxxx.Servlet;

import java.io.IOException;
import java.util.List;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/*
 *  request作用域
 *  	通过该对象可以在一个请求中传递数据,作用范围: 在一次请求中有效,即服务器跳转有效。(请求转发跳转时有效)
 *  	//设置域对象内容
 *  	request.setAttribute(String name,Object value);
 *  	//获取域对象内容
 *  	reuquest.getAttribute(String name);
 *  	//删除域对象内容
 *  	request.removeAttribute(String name);
 */



@WebServlet("/S9")
public class TestServlet09 extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			System.out.println("Servlet09......");
		
		//获取域对象的内容
		String name = (String) request.getAttribute("name");
		System.out.println("name: "+ name);
		
		Integer age = (Integer) request.getAttribute("age");
		System.out.println("age: "+ age);
		
		List<String> list = (List<String>) request.getAttribute("list");
		System.out.println(list.get(0));
		
			
	}
		
}
